#!/usr/bin/env bash
cd docs
function create_venv {
  python3 -m venv .venv
}

function activate_venv {
  source .venv/bin/activate
}

function install_req {
  pip install -r ../docs/requirements.txt
}

function generate_docs {
  make SPHINX_OPTS="-W" html
}

function usage {
  echo "  Usage:"
  echo "    1. bash makedocs setup # if setup is not done."
  echo "    2. bash makedocs       # if setup is done and building docs is needed"
}

case $@ in
  "")       activate_venv; generate_docs; exit 0 ;;
  setup)    create_venv; activate_venv; install_req; generate_docs; exit 0 ;;
  *)        echo "Unknown parameters $@"; usage; exit 1 ;;
esac
